"""author: zsw
   data: 2021/11/10
   project: aaaaaaa我爱学习
"""


import random
d1={"ad":"ad","ac":"ac","sd":"sd","vf":"vf","fe":"fe"}
lst1=list(d1.keys())
lst2=list(d1.values())
c=0
while 1:
    i=lst1[c]
    b=random.choice(lst2)
    if b==None:
        break
    elif i!=b:
        print(i,b)
        lst2.remove(b)
        c=c+1
    else:
        pass





Scar=[]
for i in range(3):
    username1 = input("请输入用户名：")
    if username1=='quit':
        break
    else:
        userpasswd1 = input("请输入密码：")
        if userpasswd1=='quit':
            break
        elif username1=="root" and userpasswd1=="123456":
            print("登陆成功")
            userbudget = input("您的预算为：")
            goods = {'1': {'name': '苹果', 'prince': 1.2}, '2': {'name': '香蕉', 'prince': 5.5}}  # 商品列表
            if userbudget=='quit':
                break
            else:
                Vprice = input("查看商品价格？")
                if Vprice=='quit':
                    break
                elif Vprice=='y':
                    print(goods)
                else:
                    pass
                Vshop = input("查看已购信息？")
                if Vshop=='quit':
                    break
                elif Vshop=='y':
                    print("您购买的商品为：",Scar,"您的余额为：",userbudget)
                else:
                    pass
                userbudget = float(userbudget)
                goods2 = list([item['prince'] for item in goods.values()]) #商品的价格列表
                while 1:
                    shopping1 = input("您要购买的商品编号为：")
                    if shopping1=='quit':
                        break
                    elif shopping1 not in goods:
                        print("没有该商品,请重新输入商品编号",goods)
                    else:
                        shopping2 = input("您要购买该商品的数量为：")
                        if  shopping2=='quit':
                            break
                        else:
                            shopping2=float(shopping2)
                            if shopping1 in goods and shopping2 * (goods2[int(shopping1) - 1]) <= userbudget:
                                userbudget = userbudget - shopping2 * goods2[int(shopping1) - 1]
                                print("你的余额为：", userbudget)
                                Scar.append([goods[shopping1]['name'],shopping2])
                            else:
                                print("余额不足")
                                print("您购买的商品为：",Scar,"您的余额为：",userbudget)
                break
        else:
            print("登陆失败，请重新登录")
















